home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_400 / 414_02 / portable / newterm.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-06-17  |  3.3 KB  |  130 lines

  1. #include <stdlib.h>
  2. #ifndef NO_MEMORY_H
  3. #include <memory.h>
  4. #endif
  5. #define    CURSES_LIBRARY    1
  6. #include <curses.h>
  7. #undef    newterm
  8.  
  9. #ifdef PDCDEBUG
  10. char *rcsid_newterm = "$Header: C:\CURSES\portable\RCS\newterm.c 2.1 1993/06/18 20:20:31 MH Rel MH $";
  11. #endif
  12.  
  13. #if    EMALLOC
  14. void*    emalloc( size_t );
  15. void*    ecalloc( size_t, size_t );
  16. void    efree( void* );
  17. #endif
  18.  
  19.  
  20.  
  21.  
  22. #if 0
  23. /*man-start*********************************************************************
  24.  
  25.   newterm()    - open new terminal
  26.  
  27.   X/Open Description:
  28.      A program which outputs to more than one terminal should use
  29.      for each terminal instead of initscr().  The newterm() function
  30.      should be called once for each terminal.  It returns a value of
  31.      type SCREEN* which should be saved as a reference to that terminal.
  32.      The arguments are the type of of terminal to be used in place of
  33.      TERM (environment variable), a file pointer for output to the
  34.      terminal and another file pointer for input from the terminal.  The
  35.      program must also call endwin() for each terminal no longer being
  36.      used.
  37.  
  38.   PDCurses Description:
  39.      This routine is a quick hack.  It is basically a copy of initscr()
  40.      with the appropriate arguments being passed.  There is no formal
  41.      support yet for dual monitor systems.  This is almost, but not
  42.      quiet, a NOP.
  43.  
  44.      outfd and infd are ignored, but required for portability.
  45.  
  46.   X/Open Return Value:
  47.      The newterm() function returns stdscr on success otherwise ERR is
  48.      returned.
  49.  
  50.   X/Open Errors:
  51.      No errors are defined for this function.
  52.  
  53.   PDCurses Errors:
  54.      It is an error to open the same SCREEN more than once.
  55.  
  56.   Portability:
  57.      PDCurses    SCREEN* newtern( char* type, FILE outfd, FILE infd );
  58.      X/Open Dec '88    SCREEN* newtern( char* type, FILE outfd, FILE infd );
  59.      BSD Curses    
  60.      SYS V Curses    SCREEN* newtern( char* type, FILE outfd, FILE infd );
  61.  
  62. **man-end**********************************************************************/
  63.  
  64. SCREEN*    newterm( char *type, FILE *outfd, FILE *infd )
  65. {
  66. #ifdef    TC
  67. #  pragma argsused
  68. #endif
  69. extern    void*    mallc();    /* malloc(size)        */
  70. extern    void*    callc();    /* calloc(num,size)    */
  71. extern    void    fre();        /* free(ptr)        */
  72.  
  73. extern    void*    malloc();
  74. extern    void*    calloc();
  75. extern    void    free();
  76.  
  77. #ifdef PDCDEBUG
  78.     if (trace_on) PDC_debug("newterm() - called\n");
  79. #endif
  80.  
  81.     if  (_cursvar.alive)
  82.         return( ERR );
  83.  
  84.     if  (_cursvar.emalloc == EMALLOC_MAGIC)
  85.     {
  86. #if    EMALLOC
  87.         memset(&_cursvar, 0, sizeof(SCREEN));
  88.         _cursvar.emalloc = TRUE;
  89.         mallc = emalloc;
  90.         callc = ecalloc;
  91.         fre   = efree;
  92. #endif
  93.     }
  94.     else
  95.     {
  96.         memset(&_cursvar, 0, sizeof(SCREEN));
  97.         mallc = malloc;
  98.         callc = calloc;
  99.         fre   = free;
  100.     }
  101.     PDC_scr_open(&_cursvar, 0);
  102.     _cursvar.orig_cursor = _cursvar.cursor;
  103.     _cursvar.orig_font = PDC_get_font();
  104.     _cursvar.orgcbr = PDC_get_ctrl_break();
  105.     _cursvar.blank = ' ';
  106. #ifdef    FLEXOS
  107.     _flexos_16bitmode();
  108. #endif
  109.     savetty();
  110.     LINES = PDC_get_rows();
  111.     COLS = PDC_get_columns();
  112.  
  113.     if ((curscr = newwin(LINES, COLS, 0, 0)) == (WINDOW *) ERR)
  114.     {
  115.         return( ERR );
  116.     }
  117.     if ((stdscr = newwin(LINES, COLS, 0, 0)) == (WINDOW *) ERR)
  118.     {
  119.         return( ERR );
  120.     }
  121.     curscr->_clear = FALSE;
  122. #ifdef    REGISTERWINDOWS
  123.     _cursvar.refreshall = FALSE;
  124.     _inswin(stdscr, (WINDOW *)NULL);
  125. #endif
  126.     _cursvar.alive = TRUE;
  127.     return( &_cursvar );
  128. }
  129. #endif
  130.